package com.zcf.utils;//package com.zcf.utils;
//
//import java.io.File;
//import java.io.FileInputStream;
//import java.io.IOException;
//import java.io.OutputStream;
//import java.net.URLEncoder;
//import java.text.SimpleDateFormat;
//import java.util.*;
//import java.util.regex.Matcher;
//import java.util.regex.Pattern;
//import cn.hutool.core.collection.CollUtil;
//import cn.hutool.poi.excel.BigExcelWriter;
//import cn.hutool.poi.excel.ExcelUtil;
//import org.apache.poi.hssf.usermodel.HSSFDateUtil;
//import org.apache.poi.ss.usermodel.*;
//import cn.hutool.core.io.FileUtil;
//import cn.hutool.poi.excel.ExcelReader;
//import cn.hutool.poi.excel.BigExcelWriter;
//import cn.hutool.poi.excel.ExcelUtil;
//import com.baomidou.mybatisplus.mapper.EntityWrapper;
//import com.baomidou.mybatisplus.plugins.Page;
//import org.apache.poi.ss.usermodel.Sheet;
//import org.apache.poi.ss.usermodel.Workbook;
//import org.apache.poi.ss.util.CellRangeAddress;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//import javax.servlet.ServletOutputStream;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//@RestController
//@RequestMapping("/common")
//public class CommonController {
///**
//     * 测试导出excel并下载
//     * @param employeeId
//     * @param startDate
//     * @param endDate
//     */
//    @GetMapping("getExcel")
//    public void getExcel(Integer employeeId, String startDate, String endDate,HttpServletResponse response) {
//        List<List<String>> listMap=new ArrayList<>();
//        List<String> list1=new ArrayList<>();
//        list1.add("客户姓名");
//        list1.add("客户电话");
//        list1.add("任务名称");
//        list1.add("话术名称");
//        list1.add("接通状态");
//        list1.add("通话时长");
//        list1.add("客户意向等级");
//        listMap.add(list1);
//        for(int i=0;i<10;i++){
//            List<String> map1=new ArrayList<>();
//            map1.add("zs11"+i);
//            map1.add("122"+i);
//            map1.add("rw"+i);
//            map1.add("hs"+i);
//            map1.add("thzt"+i);
//            map1.add("thsc"+i);
//            map1.add("khyxdj0"+i);
//            listMap.add(map1);
//        }
//
////        if(customerList!=null&&customerList.size()>0){
////            for(Customer customer:customerList){
////
////
////                Map<String,Object> map=new LinkedHashMap<>();
////                map.put("客户姓名",customer.getCustomerName());
////                map.put("客户电话",customer.getCustomerPhone());
////                map.put("任务名称","");
////                map.put("话术名称","");
////                map.put("接通状态","");
////                map.put("通话时长","");
////                map.put("客户意向等级","");
////                listMap.add(map);
////                //获取一个客户的所有通话记录信息
////                List<HashMap> taskCustomerList=taskCustomerDao.selectCustomerCallLogs(customer.getCustomerPhone(),userId+"",1,"0");
////
////                if(taskCustomerList.size()>0&&taskCustomerList!=null){
////                    for (HashMap taskCustomer:taskCustomerList){
////                        Map<String,Object> map1=new LinkedHashMap<>();
////                        map1.put("客户姓名","");
////                        map1.put("客户电话","");
////                        map1.put("任务名称",taskCustomer.get("task_name"));
////                        map1.put("话术名称",taskCustomer.get("s_name"));
////                        String jtStr="";
////                        if("1".equals(taskCustomer.get("call_state").toString())){
////                            jtStr="已接通";
////                        }else if("2".equals(taskCustomer.get("call_state").toString())){
////                            jtStr="无人接听";
////                        }else if("3".equals(taskCustomer.get("call_state").toString())){
////                            jtStr="停机";
////                        }else if("4".equals(taskCustomer.get("call_state").toString())){
////                            jtStr="空号";
////                        }else if("5".equals(taskCustomer.get("call_state").toString())){
////                            jtStr="占线";
////                        }else if("6".equals(taskCustomer.get("call_state").toString())){
////                            jtStr="关机";
////                        }else if("7".equals(taskCustomer.get("call_state").toString())){
////                            jtStr="拒接";
////                        }else if("8".equals(taskCustomer.get("call_state").toString())){
////                            jtStr="无法接通";
////                        }else{
////                            jtStr="呼叫失败";
////                        }
////
////                        map1.put("接通状态",jtStr);
////                        map1.put("通话时长",DateUtils.formatTime((long) Integer.parseInt(taskCustomer.get("duration").toString())));
////                        map1.put("客户意向等级",taskCustomer.get("customer_rank"));
////                        listMap.add(map1);
////                    }
////                }
////
////                listNum.add(taskCustomerList.size());
////
////            }
////        }
//        //合并单元格
////        if(listNum!=null&&listNum.size()>0){
////            Integer fr=1;
////            for(int i=0;i<=listNum.size()-1;i++){
////
////                if(listNum.get(i)!=0){
////
////                    sheet.addMergedRegionUnsafe(new CellRangeAddress(
////                            fr, //first row (0-based)
////                            fr+listNum.get(i), //last row  (0-based)
////                            0, //first column (0-based)
////                            0  //last column  (0-based)
////                    ));
////                    sheet.addMergedRegionUnsafe(new CellRangeAddress(
////                            fr, //first row (0-based)
////                            fr+listNum.get(i), //las row  (0-based)
////                            1, //first column (0-based)
////                            1  //last column  (0-based)
////                    ));
////                    fr=fr+listNum.get(i);
////                }
////                fr=fr+1;
////
////            }
////        }
//        try {
//            String excelName="test";
//            BigExcelWriter writer = (BigExcelWriter) ExcelUtil.getBigWriter();
//            //writer.merge(rows.size() - 1, "客户信息");
//            //合并单元格后的标题行，使用默认标题样式
//            Workbook workbook = writer.getWorkbook();
//            //writer.merge(row1.size()-2, "测试标题");
//            workbook.setSheetName(0, excelName);
//            int fr=0;
//            Sheet sheet = workbook.getSheetAt(0);
//            sheet.addMergedRegionUnsafe(new CellRangeAddress(
//                    fr, //first row (0-based)
//                    fr+1, //las row  (0-based)
//                    2, //first column (0-based)
//                    4  //last column  (0-based)
//            ));
//            excelExp(writer,excelName,listMap,response);
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//    }
//	
//	/**
//     * 导出excel
//     * @param excelName 文件名称
//     * @param listMap 导出的列表信息
//     * @param response
//     * @throws IOException
//     */
//    public static void excelExp(BigExcelWriter writer, String excelName, List<List<String>> listMap, HttpServletResponse response) throws IOException {
//
////        List<Integer> listNum=new ArrayList<>();
//        List<List<String>> rows = CollUtil.newArrayList(listMap);
//        // 通过工具类创建writer
//
//     /*   Row row = sheet.createRow(1);
//        Cell cell = row.createCell(4);
//        cell.setCellValue("women");*/
//        // 一次性写出内容，使用默认样式
//        writer.write(rows);
//        //response为HttpServletResponse对象
//        response.setContentType("application/vnd.ms-excel;charset=utf-8");
//        //test.xls是弹出下载对话框的文件名，不能为中文，中文请自行编码
//        response.setHeader("Content-Disposition","attachment;filename="+new String(excelName.getBytes("gb2312"), "ISO8859-1" )+".xlsx");
//        ServletOutputStream out=response.getOutputStream();
//        writer.flush(out);
//        // 关闭writer，释放内存
//        writer.close();
//    }
//}